{% extends 'index.html' %}
{% load static %}

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>title</title>
</head>

<body>

{% block title %}
    <span class="navbar-page-title"> 军事需求知识百科 - 百科词条 </span>
{% endblock %}


{% block content %}
    <div class='container-fluid'>
        <!-- 添加记录 -->
        {#        <a class='my-btn-a  my-btn' href="{% url 'add_wikipedia_entry' %}"#}
        {#           style="float: left;margin-left: 10px;">添加</a>#}
        <button class="my-btn" style="margin: 0 0 0 10px;float: left" onclick="javascript:location.href='{% url 'add_wikipedia_entry' %}'">
            添加
        </button>

        <form action="{% url 'search_wikipedia_entry' %}">
            <button class='my-btn' type="submit"
                    style="float: right;margin-left: 20px;margin-right: 10px">搜索
            </button>
            <input type="text" name="wikipedia_entry_name" id="wikipedia_entry_name" class="form-control my-input"
                   placeholder="请输入要搜索的百科词条名称"
                   style="width:210px;float: right">
        </form>


        <div class="form-group" style="margin: 50px 10px;padding: 10px; background-color: #ffffff">
            <!-- 页面信息展示 -->
            <table class="my-table" style="width: 100%">

                <thead>
                <tr>
                    <th style="width:5%;text-align: center;">序号</th>
                    <th style="width:20%;text-align: center;">词条名称</th>
                    <th style="width:25%;text-align: center;">词条内容</th>
                    <th style="width:20%;text-align: center;">操作</th>
                </tr>
                </thead>
                <tbody>
                {% for single_data in knowledge_card_obj %}
                    <tr style="text-align: center">
                        <td>{{ forloop.counter }}</td>
                        <td>{{ single_data.name }}</td>
                        <td>{{ single_data.content }}</td>
                        <td>
                            {#                            <a style="padding: 9px 10px" href="{% url 'edit_wikipedia_entry' single_data.id %}"#}
                            {#                               class="my-btn-a my-btn">编辑</a>#}
                            <button class="my-btn"
                                    onclick="javascript:location.href='{% url 'edit_wikipedia_entry' single_data.id %}'">
                                编辑
                            </button>

                            <button class="my-btn" onclick="model_del({{ single_data.id }})">删除</button>
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
{% endblock %}

{% block myjs %}
    <script>
        document.getElementById("jsxqzsbk").style.display = 'block';
        document.getElementById("bkct").style.backgroundColor = 'rgba(30,21,21,0.44)';


        /**
         * 删除数据
         */
        function model_del(id) {
            // 生成路径
            var url = "{% url 'delete_wikipedia_entry' 0  %}";
            url = url.replace(/0/, id);
            // 确认框
            zdconfirm('系统确认框', '你确认删除该条数据吗？', r => r ? window.location.href = url : '');
        }
    </script>
{% endblock %}

</body>

</html>